package com.excesys.exsecs.energy.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.excesys.exsecs.common.core.util.R;
import com.excesys.exsecs.common.excel.annotation.RequestExcel;
import com.excesys.exsecs.energy.entity.BumDevEnroll;
import com.excesys.exsecs.energy.entity.DevAreaMap;
import com.excesys.exsecs.energy.service.AmmeterFlowService;
import com.excesys.exsecs.energy.service.DevEnrollService;
import com.excesys.exsecs.energy.vo.DevEnrollExcelImportVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 电表流水查询
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/ammeterFlow")
@Tag(name = "电表流水查询")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AmmeterFlowController {
    private final AmmeterFlowService ammeterFlowService;
	/*
	*
	*查询电表 物模型值
	*/
	@Operation(summary = "电表流水查询" , description = "电表流水查询" )
	@GetMapping("/query" )
	//@PreAuthorize("@pms.hasPermission('twinops_devAreaMap_view')" )
	public List<Map<String, Object>> getJsonValuesWithTime(@RequestParam("keys") List<String> keys, @RequestParam String unitNo, @RequestParam String startTime, @RequestParam String endTime) {
		List<Map<String, Object>> list = new ArrayList<>();
		if(keys.size()>0){
			list =  ammeterFlowService.selectValuesFromJson(keys,unitNo,startTime,endTime);
		}
	    return list;
	}

	/*
	 *
	 *查询电表 有功电能最大值
	 */
	@Operation(summary = "电表流水查询" , description = "电表流水查询" )
	@GetMapping("/queryMaxDemand" )
	//@PreAuthorize("@pms.hasPermission('twinops_devAreaMap_view')" )
	public List<Map<String, Object>> queryMaxDemand(@RequestParam("key")String key, @RequestParam String unitNo, @RequestParam String startTime, @RequestParam String endTime) {
		return ammeterFlowService.queryMaxDemand(key,unitNo,startTime,endTime);
	}

	/*
	 *
	 *查询电表  某个月每天有功电能最大值
	 */
	@Operation(summary = "电表流水查询" , description = "电表流水查询" )
	@GetMapping("/queryMaxDemandByMonth" )
	//@PreAuthorize("@pms.hasPermission('twinops_devAreaMap_view')" )
	public List<Map<String, Object>> queryMaxDemandByMonth(@RequestParam("key")String key, @RequestParam String unitNo,@RequestParam String startTime, @RequestParam String endTime) {
		return ammeterFlowService.queryMaxDemandByMonth(key,unitNo,startTime,endTime);
	}


}